home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet internetowy / Czytniki RSS / RSS Bandit 1.3.0.42 / RssBandit Installer.msi / _172FF5180BC61D3C6D240F14338A23AA / _AEAF254EC6F64D5AA0B3A33BDD1591F7 < prev    next >
Text File  |  2005-05-26  |  1KB  |  46 lines

  1. using System;
  2. using System.Xml.XPath;
  3. using Syndication.Extensibility;
  4. using System.Windows.Forms;
  5. using System.Diagnostics;
  6.  
  7. namespace BlogExtension.MailThis {
  8.  
  9.     public class EmailThisPlugin:IBlogExtension {
  10.  
  11.         public bool HasConfiguration { get {return false; } }
  12.         public bool HasEditingGUI{ get {return false; } }
  13.  
  14.         public void Configure(IWin32Window parent){
  15.             /* yeah, right */
  16.         }
  17.  
  18.         public string DisplayName { get { return Resource.Manager["RES_MenuEmailThisCaption"]; } }
  19.  
  20.         public void BlogItem(System.Xml.XPath.IXPathNavigable rssFragment, bool edited) {
  21.  
  22.             LaunchEmail(GetMailUrl(rssFragment.CreateNavigator()));
  23.         }
  24.  
  25.         private String GetMailUrl(XPathNavigator nav) {
  26.             const String TEMPLATE_STRING = @"mailto:receiver@example.com?subject={0}&body={1}";
  27.  
  28.             return String.Format(TEMPLATE_STRING,
  29.                 this.HandleCharacters(nav.Evaluate("string(//item/title/text())")),
  30.                 this.HandleCharacters(nav.Evaluate("string(//item/link/text())")));
  31.         }
  32.  
  33.         private void LaunchEmail(String mailUrl) {
  34.             Process.Start(mailUrl);
  35.         }
  36.  
  37.         private static string quote = new String('"', 1);
  38.  
  39.         private string HandleCharacters(object input) {
  40.  
  41.             return input.ToString().Replace(System.Environment.NewLine, "%0A").Replace(quote, "%22").Replace("&", "%26");
  42.         }
  43.  
  44.     }
  45. }
  46.